package com.mini.service.impl;

import com.mini.dao.DatasourceInfoMapper;
import com.mini.pojo.basic.DatasourceInfo;
import com.mini.service.DatasourceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DatasourceInfoServiceImpl implements DatasourceInfoService {

    @Autowired
    private DatasourceInfoMapper datasourceInfoMapper;

    public void addDatasourceInfo(DatasourceInfo datasourceInfo) {
        datasourceInfo.setCreatedBy("test");
        datasourceInfo.setCreatedTime(new Date());
        datasourceInfo.setUpdatedBy("test");
        datasourceInfo.setUpdatedTime(new Date());
        datasourceInfoMapper.addDatasourceInfo(datasourceInfo);
    }

    public void updateDatasourceInfo(DatasourceInfo datasourceInfo) {
        datasourceInfo.setUpdatedBy("test");
        datasourceInfo.setUpdatedTime(new Date());
        datasourceInfoMapper.updateDatasourceInfo(datasourceInfo);
    }

    public void removeDatasourceInfo(int datasourceId) {
        DatasourceInfo datasourceInfo1 = datasourceInfoMapper.queryDatasourceInfo(datasourceId);
        datasourceInfo1.setUpdatedBy("test");
        datasourceInfo1.setUpdatedTime(new Date());
        datasourceInfoMapper.removeDatasourceInfo(datasourceInfo1);
    }

    public DatasourceInfo queryDatasourceInfo(int datasourceId) {
        return datasourceInfoMapper.queryDatasourceInfo(datasourceId);
    }

    public List<DatasourceInfo> queryAllDatasourceInfo() {
        return datasourceInfoMapper.queryAllDatasourceInfo();
    }
}
